import Vue from 'vue'
import Vuex from 'vuex'
import {GET_TOKEN} from '@/utils/storage.js'

Vue.use(Vuex)

const TOKEN_KEY='TOUTIAO_USER'
export default new Vuex.Store({
  state: {
    //用户的登录状态信息
    // user:JSON.parse(window.localStorage.getItem('TOUTIAO_USER'))
    user:GET_TOKEN(TOKEN_KEY)|| null
  },
  mutations: {
    SET_TOKEN (state,user) {
      window.localStorage.setItem('TOUTIAO_USER',JSON.stringify(user))
      // SET_TOKEN(TOKEN_KEY,state.user)
      state.user=user
    }
  },
  actions: {
  },
  modules: {
  }
})
